// 子组件
import React from 'react';
import { Consumer } from './grandpa'

function ChildComponent(props) {
    const sendDataToParent = () => {
        props.sendDataToParent("Hello from child");
    };

    return <div>
        我是子组件
        父组件值 :{props.data}
        <button onClick={sendDataToParent}>Send Data</button>
        <Consumer>
            {value => {
                return `${value.username}接收`
            }}
        </Consumer>
    </div>;
}

export default ChildComponent;
